using System.Drawing;
using System;
static class Renderer
{
  static GEN gn=Generator.genLocatingLocs;
  static REN rn=Renderer.NextToEachOther;
  static int margin=30;
  static int vSplit=70;
  static void RenderResStamp(Graphics g,float ctrX,float ctrY,int rotation)
  {
    float sRad=3.6f;
    float bRad=6f;
    Pen pen=new Pen(Color.Black,0.2f);
    g.FillPie(Brushes.Black,ctrX-bRad,ctrY-bRad,bRad*2,bRad*2,90+rotation,90);
    g.FillPie(Brushes.Black,ctrX-bRad,ctrY-bRad,bRad*2,bRad*2,270+rotation,90);
    g.FillEllipse(Brushes.White,ctrX-sRad,ctrY-sRad,sRad*2,sRad*2);
    g.FillPie(Brushes.Black,ctrX-sRad,ctrY-sRad,sRad*2,sRad*2,0+rotation,90);
    g.FillPie(Brushes.Black,ctrX-sRad,ctrY-sRad,sRad*2,sRad*2,180+rotation,90);
    g.DrawEllipse(pen,ctrX-bRad,ctrY-bRad,bRad*2,bRad*2);
  }
  public static void Render(Graphics g,string str)
  {
    rn(g,gn());
    g.DrawString(str,new Font("verdana",10),Brushes.Black,40,8);
    //(int)(-(60*DateTime.Now.Hour+DateTime.Now.Minute)/10f)
    RenderResStamp(g,280,16,15);
  }
  delegate string[] GEN();
  delegate void REN(Graphics g,string[] strings);


  public static void FourDVPPrinters(Graphics g,string[] strings)
  {

    new Bar39(strings[0]).Paint(g,50,50);
    new Bar39(strings[1]).Paint(g,300,50);
    new Bar39(strings[2]).Paint(g,50,180);
    new Bar39(strings[3]).Paint(g,300,180);
  }
  public static void GridAllignTilt(Graphics g,string[] strings)
  {
    float width=0.75f;
    int counter=0;
    int barsInRow=6;
    int hSplit=130;
    int vSplit=43;
    //float ratio=1.5f;
    foreach(string str in strings)
    {
      //ratio=1.5f+(counter%barsInRow)*0.5f;

      Bar39 bar=new Bar39(str,width,width*2.5f);
      //width+=0.015f;
      int left=margin+counter%barsInRow*hSplit;

      int vTilt=counter%barsInRow%2==0?0:vSplit/2;

      int top=counter/barsInRow*vSplit+margin+vTilt;
      //int topTilt=(left%2==0)?0:(int)(vSplit/2.5);
      bar.Paint(g,left,top);
      counter++;
    }
  }
  public static void GridAllign(Graphics g,string[] strings)
  {
    float width=0.75f;
    int counter=0;
    int barsInRow=4;
    int hSplit=200;
    int vSplit=100;
    //float ratio=1.5f;
    foreach(string str in strings)
    {
      Bar39 bar=new Bar39(str,width,width*3f);
      int left=margin+counter%barsInRow*hSplit;
      int top=counter/barsInRow*vSplit+margin;
      bar.Paint(g,left,top);
      counter++;
    }
  }
  public static void NextToEachOther(Graphics g,string[] strings)
  {
    int distance=30;
    int left=margin;
    int top=margin;
    int counter=0;
    foreach(string str in strings)
    {
      Bar39 bar=new Bar39(str,0.6f,2.0f);
      if(left+bar.Width>827-margin)//827 it the A4 width
      {
        top+=vSplit;
        left=margin;
      }
      bar.Paint(g,left,top);
      left+=(int)bar.Width+distance;
      counter++;
    }
  }
  public static void NextToEachOtherTilt(Graphics g,string[] strings)
  {
    int distance=50;
    int left=margin;
    int top=margin;
    int counter=0;
    int tiltCnt=0;
    foreach(string str in strings)
    {
      Bar39 bar=new Bar39(str);
      if(left+bar.Width>827-margin)//827 it the A4 width
      {
        top+=vSplit;
        left=margin;
        tiltCnt=0;
      }
      int vTilt=tiltCnt%2==0?0:vSplit/2;
      bar.Paint(g,left,top+vTilt);
      left+=(int)bar.Width+distance;
      counter++;
      tiltCnt++;
    }
  }
}